﻿using System;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine.Networking;

public class InitSuit : CharacterBehaviour, IEditable
{
    [CompilerGenerated]
    private static Func<Asset, bool> <>f__am$cache1;
    public string suitName;

    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        base.OnDeserialize(reader, initialState);
    }

    public void OnEditorGUI()
    {
        this.suitName = GameGUI.AssetNameField("suitName", this.suitName);
    }

    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        bool flag;
        bool flag2 = base.OnSerialize(writer, forceAll);
        return (flag | flag2);
    }

    public override void OnStartAuthority()
    {
        base.OnStartAuthority();
        this.StartWaitForEndOfFrame(delegate {
            Inventory component = base.GetComponent<Inventory>();
            Asset asset = AssetManager.GetAsset(this.suitName);
            if (asset == null)
            {
                if (<>f__am$cache1 == null)
                {
                    <>f__am$cache1 = x => x.gameObject.GetComponent<Suit>() != null;
                }
                asset = AssetManager.GetAllSuitAssets().Where<Asset>(<>f__am$cache1).GetRandomElement<Asset>();
            }
            component.CreateSuit(asset.name);
        });
    }

    private void UNetVersion()
    {
    }
}

